Skip to content

feat(windows): add 'Follow system theme' option for dark mode#10815

Open
BenJule wants to merge 1 commit into
bambulab:masterfrom
BenJule:feat/auto-dark-mode-windows
Open

feat(windows): add 'Follow system theme' option for dark mode#10815
BenJule wants to merge 1 commit into
bambulab:masterfrom
BenJule:feat/auto-dark-mode-windows

Conversation

@BenJule

@BenJule BenJule commented May 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #10800.

On macOS, BambuStudio already follows the system dark/light theme automatically via EVT_SYS_COLOUR_CHANGED. On Windows this event handler was guarded with #ifndef __WINDOWS__, so theme changes were silently ignored and users had to toggle dark mode manually in Preferences.

This PR adds a "Follow system theme" checkbox directly below the existing "Enable dark mode" toggle in Preferences → Other. When checked:

  • The manual "Enable dark mode" checkbox is disabled (grayed out)
  • The current Windows system theme is applied immediately
  • Any subsequent system theme changes (e.g. switching in Windows Settings → Personalisation → Colors) are detected via WM_SYSCOLORCHANGE and the UI updates automatically

When unchecked, behavior is unchanged — the manual toggle controls dark mode as before.

Implementation

File Change
GUI_Utils.hpp EVT_SYS_COLOUR_CHANGED now calls update_dark_config() + on_sys_color_changed() on Windows when dark_mode_follow_system == "1"
GUI_App.cpp dark_mode() returns check_dark_mode() (system appearance) instead of stored config when follow-system is active; on startup, syncs config from system if follow-system is active
MainFrame.cpp on_sys_color_changed() calls force_colors_update() and update_ui_from_settings() on all platforms for a full UI refresh
Preferences.hpp/.cpp New m_dark_mode_follow_system_checkbox; "Follow system theme" checkbox with immediate apply + mutual exclusion with manual toggle

The stored config key is dark_mode_follow_system ("0" by default, "1" when enabled) — fully backwards compatible.

Test plan

  • Windows: enable "Follow system theme" → manual toggle grays out, current system theme applied
  • Windows: switch system between light/dark in Settings → Personalisation → Colors → app follows without restart
  • Windows: disable "Follow system theme" → manual toggle re-enabled, theme stays at last value
  • Windows: restart with "Follow system theme" enabled → correct theme applied on launch
  • macOS/Linux: no change in behavior, existing auto-follow still works
  • Preferences dialog dark mode updates correctly when toggling follow-system

@BenJule BenJule force-pushed the feat/auto-dark-mode-windows branch 2 times, most recently from 5bf2121 to 770f7d2 Compare May 21, 2026 08:55
@BenJule BenJule closed this Jun 7, 2026
@BenJule BenJule deleted the feat/auto-dark-mode-windows branch June 7, 2026 10:09
@BenJule BenJule restored the feat/auto-dark-mode-windows branch June 7, 2026 11:38
@BenJule BenJule reopened this Jun 7, 2026
@BenJule

BenJule commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

Apologies — this PR was closed by mistake on 2026-06-07, and that was an error on my side, not a deliberate decision to withdraw the change.

It happened as an unintended side effect of a branch cleanup in my fork: deleting the head branch automatically closed this PR. The contribution still stands. I have restored the branch and reopened the PR. Sorry for the noise and any confusion this caused.

Rebased onto current master and reduced to the feature's own source changes;
removed translation catalogs and unrelated files carried over from the branch base.
@BenJule BenJule force-pushed the feat/auto-dark-mode-windows branch from 770f7d2 to 63a9458 Compare June 8, 2026 05:24
@BenJule

BenJule commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Force-pushed: rebased onto current master and reduced this PR to the feature's own source changes. The previous revision had inadvertently carried translation-file (.po/.pot) edits, generated web resources, and unrelated source changes (string fixes belonging to #10811/#10813/#10814) over from the branch base — those are now removed. Heads-up: this feature series shares a few central GUI files (e.g. GUI_App.cpp, MainFrame.cpp, Preferences.hpp), so there is some overlap between my feature PRs.

@tonghao-bbl

Copy link
Copy Markdown
Contributor

Hi @BenJule Can you make this option a combox?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto Dark Mode: Follow Windows 11 System Theme

2 participants